#ifndef MAP_H_
#define MAP_H_

#include <fstream>
#include <string>
#include <SFML/Graphics.hpp>
#include "Block.h"
#include "var_define.h"
#include <iostream>

#include "Pnj.h"
#include "NameList.h"

using namespace std;
using namespace sf;

class Map {
	public:
		Map(string filename = "");

		void	loadMap();
		void	loadZones(fstream * zonesFile);
		void	loadObjs(fstream * objsFile);
		bool	finFichier();
		bool	canMoveOn(int x_origin, int y_origin, int direction);

		string	getID();
		string	getName();
		string	getDescription();
		int		getWidth();
		int		getHeight();
		Sprite*	getP_Sprite();
		Sprite*	getP_Calque();

		inline	void setSprite(Sprite* sprite) { spriteMap = *sprite; }
		inline	void setCalque(Sprite* sprite) { calqueSup = *sprite; }

		void	SubRect();

		void	setMap(Map map);

		void    setPnj(int i, int j, bool b);
		bool    getPnj(int i, int j);
		void    reload(string filename);

		void    setZone(int x, int y, int largeur, int hauteur,string image, bool rencontre);
        Block	getBlock(int x, int y);

		void	makeBlock(int bloc_x, int bloc_y, string bloc_img);
        void	makeHLine(int longLine, int bloc_x, int bloc_y, string bloc_img);
        void	makeVLine(int longLine, int bloc_x, int bloc_y, string bloc_img);

        inline string  getFileName() {return fileName;}
        void	makeBorder(string rep);

       /* void	stepSound();
        void	playAmbiance();
        void	stopAmbiance();
        void	switchPauseAmb();
        bool	isPlaying();
        void	resetMusic();*/

        void	viewState();

        inline	vector<Pnj>& getPnj() { return listePnj; }

        ~Map();

	private:
		string	fileName;
		string	name;
		string	des;
		int		x;
		int		y;
		Image	imgMap;
		Image	imgCalqueSup;
		Sprite	spriteMap;
		Sprite	calqueSup;
		string	ground;
		Block**	blocks;
		Block**	blocksSup;

	//	Sound	walkSound;
	//	Music	ambiance;

		vector<Pnj>	listePnj;
		NameList*	nameList;
};
#endif
